import React from 'react'
import { Button, Form, Input, Card, Space, message } from 'antd'
import { useNavigate } from 'react-router-dom'
import { reqAddHospitalSet } from '@api/hospital/hospitalSet'
export default function HospitalSetAddOrUpdate() {
  const navigate = useNavigate()
  const onFinish = async (values: any) => {
    // console.log('Success:', values)
    // console.log(values)
    // 发送请求,添加数据
    await reqAddHospitalSet(values)
    // 提示用户,添加成功
    message.success('添加医院设置成功')
    // 回到医院设置页面
    navigate(-1)
  }

  return (
    <Card>
      <Form
        name="basic"
        onFinish={onFinish}
        labelCol={{ span: 2 }}
        // wrapperCol={{ offset: 3 }}
      >
        <Form.Item
          label="医院名称"
          name="hosname"
          rules={[{ required: true, message: 'Please input your hosname!' }]}
        >
          <Input />
        </Form.Item>

        <Form.Item
          label="医院编码"
          name="hoscode"
          rules={[{ required: true, message: 'Please input your hoscode!' }]}
        >
          <Input />
        </Form.Item>

        <Form.Item
          label="api基础路径"
          name="apiUrl"
          rules={[{ required: true, message: 'Please input your apiUrl!' }]}
        >
          <Input></Input>
        </Form.Item>
        <Form.Item
          label="联系人名称"
          name="contactsName"
          rules={[
            { required: true, message: 'Please input your contactsName!' },
          ]}
        >
          <Input></Input>
        </Form.Item>
        <Form.Item
          label="联系人手机"
          name="contactsPhone"
          rules={[
            {
              required: true,
              message: 'Please input your contactsPhone!',
              pattern: /^1[3-9]\d{9}$/,
            },
          ]}
        >
          <Input></Input>
        </Form.Item>

        <Form.Item wrapperCol={{ offset: 2 }}>
          <Space>
            <Button type="primary" htmlType="submit">
              保存
            </Button>
            <Button
              onClick={() => {
                navigate(-1)
              }}
            >
              返回
            </Button>
          </Space>
        </Form.Item>
      </Form>
    </Card>
  )
}
